3130 ' del!(1) > 0, del!(0) is pos for center move, neg for size change
3132 ' del!(2), del!(3) > 0 if relate dimension changes by factor f!
3135 F! =319/199 'factor relating width to height in r mode
3140 BD = 30 ' loops before blinking
3145 SEENBOXHELP = 0 'flag to show help menu first time
3150 DIM HS(81),VS(201) 'hold horozontal and vert line data for putting
3160 DEF FNX!(I) =XL! +(XH!-XL!)*I/319 ' screen to world coord conversion -- x
3165 DEF FNY!(I) =YH! -(YH!-YL!)*I/199 'screen to world coord conversion -- y
3170 LINE (0,0)-(319,0)
3180 GET (0,0)-(319,0),HS
3190 LINE (0,0)-(0,199)
3200 GET (0,0)-(0,199),VS
3210 CLS
3220 SEE=0 'flag for visibility of box
3230 GOSUB 3980 'init box dim
3240 RETURN ' from set up future box mode
3245 '
3250 'start main input and blink loop in box mode
3255 MINPIX!(0) = MINWIDTH!/DX! + 0.5: IF MINPIX!(0) < 1 THEN MINPIX!(0) = 1
3256 IF V!(1) - V!(0) < MINPIX!(0) THEN V!(0) = (319-MINPIX!(0))/2 : V!(1) = V!(0) + MINPIX!(0) + 0.000999999: GOSUB 3980 ' if window gets magnified, it can't blow up too far
3257 IF NOT SEENBOXHELP THEN GOSUB 3720 : GOSUB 4030 : SEENBOXHELP = -1 : GOTO 3280 'start with help screen the first time
3258 IF CANSAVE THEN PUT (0,0),BUF!,PSET ELSE GOSUB 1300 'make sure picture on screen
3259 SEE=0 : GOSUB 4030 : A$ ="c" : GOTO 3340 'start in center mode
3260 GOSUB 4030 'xor box
3270 A$ = INKEY$ : IF A$ = "" THEN BC = BC+1 : IF BC < BD THEN 3270 ELSE GOTO 3260
3280 IF LEN(A$) = 1 THEN 3340
3290 IF RIGHT$(A$,1) =CHR$(72) THEN GOSUB 3430 : GOTO 3260 'up arrow
3300 IF RIGHT$(A$,1) =CHR$(80) THEN GOSUB 3460 : GOTO 3260 'down arrow
3310 IF RIGHT$(A$,1) =CHR$(75) THEN GOSUB 3490 : GOTO 3260 'left arrow
3320 IF RIGHT$(A$,1) =CHR$(77) THEN GOSUB 3520 : GOTO 3260 'right arrow
3330 PRINT CHR$(7); : GOTO 3260
3339 ' branch to here when start box mode
3340 IF A$="c" THEN DEL!(0)=DEL!(1): DEL!(2)=0 : DEL!(3) = 0: GOTO 3260 'move center
3345 IF A$="r" THEN GOSUB 4300 : GOTO 3260 'change dimensions, relate by f!
3350 IF A$="s" THEN DEL!(0)=-DEL!(1) : DEL!(2)=0 : DEL!(3) = 0 : GOTO 3260 'change dimensions separately
3360 IF A$="+" THEN GOSUB 3640 : GOTO 3260 'double jump size
3370 IF A$="-" THEN GOSUB 3660 : GOTO 3260 'halve jump size
3375 IF A$="f" THEN GOSUB 4500 : GOTO 3260 'change relation of sides and put in r mode
3380 IF A$="h" THEN GOSUB 3720 : GOTO 3280 'display help scr + get next key
3385 IF A$="a" THEN GOSUB 4100 : RETURN 'accept new window, return to main menu
3390 IF A$="q" THEN GOSUB 3690 : RETURN 'return to main menu
3395 IF A$="k" THEN GOSUB 4200 : RETURN 'keep box in pict, return to main menu
3400 IF A$="w" THEN GOSUB 3910 : GOTO 3280 'display window param for box, return with next key
3410 PRINT CHR$(7); : GOTO 3260
3420 ' set shifts and coord indices for arrow keys
4600 FOR I = 0 TO 3 : NV!(I) = V!(I) + DEL!(I) : NEXT I
4602 IF (NV!(0) < 0) OR (NV!(1) > BV(0)) THEN PRINT CHR$(7); : RETURN 'off screen
4605 IF (NV!(2) < 0) OR (NV!(3) > BV(2)) THEN PRINT CHR$(7); : RETURN 'off screen
4610 GOTO 4680 'jump to finish with shrink box code
4620 '
4649 'START SHRINK BOX IN R MODE
4650 FOR I = 0 TO 3 : NV!(I) = V!(I) - DEL!(I) : NEXT I
4655 IF (NV!(0) > NV!(1) - MINPIX!(0)) THEN PRINT CHR$(7); : RETURN 'sides too close
4680 IF SEE THEN GOSUB 4030 'make sure box off before moving
4685 FOR I = 0 TO 3 : V!(I) = NV!(I) : NEXT I
4687 GOSUB 3980 'set new dimensions for xor
4690 RETURN ' from changing box size in r mode
4695 '
4990 'overview command
5000 SCREEN 0,0 : WIDTH 80 : COLOR 2,0
5010 GOSUB 6260
5020 PRINT" Interactive Julia Set Calculation
5030 PRINT" by Andy Harrington, Loyola University of Chicago
5035 PRINT : PRINT" AN OVERVIEW OF THE PROGRAM
5040 PRINT
5050 PRINT"ALGORITHM AND MATHEMATICAL BACKROUND
5060 PRINT" This program uses a fast machine language subroutine with integer
5070 PRINT"arithmetic to calculate approximations to Julia sets for complex functions
5080 PRINT" F(z) = z^2 - L.
5090 PRINT" We use the property of any Julia set for a polynomial that there is a
5100 PRINT"bounded region K, with the following properties:
5110 PRINT"1. The boundary of K is the Julia set.
5120 PRINT"2. No matter how many times you iterate F starting from a point in K, you stay";
5130 PRINT"in K, but if you start your iteration from outside K you are eventually drawn
5140 PRINT"off to infinity.
5150 PRINT" The program has as a parameter a maximum number of iterations, M. The
5160 PRINT"program approximates K by plotting all screen points whose first M iterates
5170 PRINT"stay in the region -2 < x < 2 and -1 < y <1. With a color monitor you can
5180 PRINT"choose three different values of M and superimpose the corresponding pictures
5190 PRINT"to see how much extra iterations affect the approximation.
5200 GOSUB 6200 : IF A$ <> " " THEN GOSUB 6230 : RETURN ' from overview
5210 GOSUB 6260 : PRINT"MAIN COMMAND PROCESSOR
5220 PRINT" The program accepts a variety of single keystroke commands.
5230 PRINT"o Redisplay this overview.
5240 PRINT"h The help menu containing the whole list of commands displayed
5250 PRINT"alphabetically.
5260 PRINT"c Clear the screen.
5270 PRINT"p Displays the parameters for the current picture without erasing first.
5280 PRINT"This way you have the opportunity to superimpose this data on your picture
5290 PRINT"before photographing. If you just want to view the parameters, clear the
5300 PRINT"screen first.
5310 PRINT"n Give ALL parameters new values and then see the associated Julia set.
5320 PRINT"j See the Julia set picture for the current parameters. Press this after you";
5330 PRINT"have set individual parameters the way you want them. If you have reentered
5340 PRINT"parameters, then the new picture is displayed as it is calculated. The end of
5350 PRINT"the calculation is indicated by the function parameters appearing on the
5360 PRINT"screen. If no parameters have been reentered, so the picture is in memory,
5370 PRINT"then it is copied immediately. The parameters do not appear when the picture
5380 PRINT"is copied from memory.
5390 PRINT"f Set the function f(z) = z^2 - L by choosing the real and imaginary parts of";
5400 PRINT"the parameter L.
5410 PRINT"i Set all three of the iteration limits discussed above.
5420 PRINT"m Reset the maximum of the three iteration limits. If the largest iteration
5430 PRINT"limit is changed, then the other two iteration limits are shifted by the same
5440 PRINT"amount.";
5450 GOSUB 6200 : IF A$ <> " " THEN GOSUB 6230 : RETURN ' from overview
5460 GOSUB 6260 : PRINT"SETTING THE SCREEN WINDOW
5470 PRINT"x Set the x coordinates of the edges of the screen.
5480 PRINT"y Set the y coordinates of the edges of the screen.
5490 PRINT"w Set the whole screen window -- both x and y limits.
5500 PRINT"b Manipulate a flashing box on the screen to graphically choose a new window
5510 PRINT"for a magnification of the current picture. The command invokes a separate
5520 PRINT"command processor, called box mode, described later on.
5530 PRINT : PRINT"DISK OPERATIONS
5540 PRINT"s Save the current parameters, the associated picture, and a comment string
5550 PRINT"to disk.
5560 PRINT"l Load something you saved before to disk.
5570 PRINT : PRINT"COMMENTS
5580 PRINT"e Enter a comment or edit a previous version. In addition to numerical data
5590 PRINT"about a picture, you can save this text to disk.
5600 PRINT"t Display the text of your comment. It will appear right under the
5610 PRINT"parameters if you press p first.
5620 PRINT:PRINT"SCREEN APPEARANCE
5630 PRINT"- Switch palettes-changes the three colors of the Julia set approximations.
5640 PRINT"0-9 New backround color code.
5650 GOSUB 6200 : IF A$ <> " " THEN GOSUB 6230 : RETURN ' from overview
5660 GOSUB 6260
5670 PRINT"BOX MODE
5680 PRINT" Enter box mode by pressing b. Then you can place a flashing box wherever
5690 PRINT"you like on the screen and use its coordinates for your next window in a blowup"
5700 PRINT"of the Julia set picture.
5710 PRINT" Pressing h in box mode gives the alphabetical help menu of all the commands"
5720 PRINT"listed below.
5730 PRINT" Initially the arrow keys move the center of the box, but if you press s or ";
5740 PRINT"r the center will be fixed and you can change the dimensions. If you press s
5750 PRINT"then the arrows separately adjust the width and height. If you press r, then
5760 PRINT"the width and height are changed together, related by a factor f, which you can ";
5770 PRINT"set. If you want to go back to moving the center, press c.
5780 PRINT" The magnitude of the changes induced by the arrow keys are doubled after
5790 PRINT"each time you press +, and halved when you press -.
5800 PRINT" You can see the coordinates of your box by pressing w. If you want the
5810 PRINT"current box coordinates to be the coordinates for your next whole window, then
5820 PRINT"press a to accept the new window coordinates and leave box mode. (You could
5830 PRINT"then press j to see the blown up Julia set.)
5840 PRINT" Instead of pressing a to leave box mode you could press q or k. Press q to";
5850 PRINT"quit without changing window parameters. Pressing k will not change window
5860 PRINT"parameters either, but it will leave a nonflashing box in your picture. (This
5870 PRINT"is so you can save the picture showing where you plan the next blowup.)
5880 PRINT"Pressing b again returns you to box mode with the box in the same place on the
5890 PRINT"screen. Then you can press a to accept the new window and j to calculate the
5900 PRINT"blown up Julia set.)";
5910 GOSUB 6200 : IF A$ <> " " THEN GOSUB 6230 : RETURN ' from overview
5920 GOSUB 6260
5930 PRINT"SUGGESTIONS ON CHOOSING PARAMETERS
5940 PRINT" If you have a monochrome graphics monitor, initially set all three iteration limits (i) to be equal. Later if you want to change the common number, use the maximum command (m).
5950 PRINT" If a Julia set does not entirely lie in the rectangle -2 < x < 2, -1 < y < 1, then this program will NOT display it correctly. This will not be aproblem if Im(L) = 0 with any allowed value of Re(L), 0 < Re(L) < 2. No neat
5960 PRINT"generalization can be made for Im(L) > 0, but for middle sized values of Re(L), fairly large values of Im(L) can be chosen, as you can see by experiment.
6100 PRINT : PRINT"DETAILS OF PARAMETER ROUNDING FOR THE ALGORITHM
6110 PRINT" The integer arithmetic used in the machine language subroutine gives the
6120 PRINT"speed of picture calculation, but there is a tradeoff in resolution. The x
6130 PRINT"coordinate of each pixel must be a multiple of 2^(-14); y, a multip[le of 2^(-
6140 PRINT"15); Re(L), of 2^(-14); and Im(L), of 2^(-13). The minimum width of a picture
6150 PRINT"therefore is 319 times 2^(-14), approximately .019. The rounded values for L
6160 PRINT"and the x limits are shown when you redisplay the parameters.
6170 GOSUB 6200 : IF A$ <> " " THEN GOSUB 6230 : RETURN ' from overview
6180 CLS : GOTO 5010 ' back to beginning of overview
6190 ' start get key
6200 A$ = INKEY$ : IF A$="" THEN 6200 ELSE RETURN ' from get key
6210 '
6220 ' start fix screen at end of overview
6230 SCREEN 1,0 : COLOR COLR, PAL : RETURN ' fromfix screen after overview
6240 '
6250 ' start clear for next page
6260 CLS :LOCATE 25,1 : PRINT"PRESS SPACEBAR FOR MORE. ENTER A COMMAND TO EXIT THE OVERVIEW." : LOCATE 1,1 :RETURN ' from clearing for next page